<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <script>
        (function() {
            if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
                handleFontSize();
            } else {
                if (document.addEventListener) {
                    document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
                } else if (document.attachEvent) {
                    document.attachEvent("WeixinJSBridgeReady", handleFontSize);
                    document.attachEvent("onWeixinJSBridgeReady", handleFontSize);  }
            }
            function handleFontSize() {
                // 设置网页字体为默认大小
                WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
                // 重写设置网页字体大小的事件
                WeixinJSBridge.on('menu:setfont', function() {
                    WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
                });
            }
        })();
    </script>
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" disabled id="username" placeholder="姓名" lay-req
                           text="姓名不能为空" autocomplete="off" class="layui-input">
                </div>
            </div>
            <input type="hidden" name="id" id="id">

            <div class="layui-form-item">
                <label class="layui-form-label required">起始日期</label>
                <div class="layui-input-block">
                    <input type="text" name="date" id="date" placeholder="年-月-日" lay-req text="日期不能为空"
                           autocomplete="off" class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">结束日期</label>
                <div class="layui-input-block">
                    <input type="text" name="edate" id="edate" placeholder="年-月-日" autocomplete="off"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">城市</label>
                <div class="layui-input-block">
                    <input type="text" name="location" id="location" placeholder="请输入城市"
                           value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">行程安排</label>
                <div class="layui-input-block">
                    <textarea name="action" id="action"  placeholder="1.行程安排不得有违法安排
2.请填写如下内容
    环境布局
    堪舆
    讲课" class="layui-textarea"></textarea>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$
        laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#edate'
        });

        $("#username").val("[[${data.username}]]");
        $("#date").val("[[${data.date}]]");
        $("#edate").val("[[${data.edate}]]");
        $("#location").val("[[${data.location}]]");
        $("#action").val("[[${data.action}]]");
        $("#id").val("[[${data.id}]]");

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            $.ajax({
                url: "/plan/edit",
                method: 'post',
                contentType: "application/json;charset=utf-8",
                data: JSON.stringify(data.field),
                dataType: 'JSON',
                success: function (data) {

                    console.log(data);
                    if (data.code == 0) {
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        window.parent.location.reload();
                    } else {
                        layer.msg(data.msg);
                    }

                }
            });


            return false;
        });

    })
    ;
</script>
</body>
</html>